package com.wo56.pushmsgcenter.business.redis;

import java.util.Map;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import redis.clients.jedis.JedisPubSub;

public class RedisMsgPubSubListener extends JedisPubSub {
	
	private ExecutorService exec = null;
	private CompletionService<Map> serv = null;
	public RedisMsgPubSubListener(){
		exec = Executors.newFixedThreadPool(10);
		serv = new ExecutorCompletionService<Map>(exec);
	}
	
	@Override
	public void onMessage(String channel, String message) {
		serv.submit(new ConsumeMsgCallable(channel,message));
		System.out.println("channel:" + channel + "-->receives message :" + message); 
	}

	@Override
	public void onPMessage(String pattern, String channel, String message) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onSubscribe(String channel, int subscribedChannels) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onUnsubscribe(String channel, int subscribedChannels) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPUnsubscribe(String pattern, int subscribedChannels) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPSubscribe(String pattern, int subscribedChannels) {
		// TODO Auto-generated method stub
		
	}  
}